<?php
$results = array('success' => TRUE, 'messages' => array());

$obj = new CQuotations();
if (!$obj->bind($_POST )) {
	$results['success'] = FALSE;
	$results['errors'] = $obj->_error;
} else {
	$obj->store();
}

header('Content-Type: text/xml');

$xml = new XmlWriter();
$xml->openMemory();
$xml->startDocument('1.0', 'UTF-8');

$xml->startElement('root');

$xml->writeElement('quote_id', $obj->quote_id);
$xml->writeElement('quote_code', $obj->quote_code);
$xml->writeElement('success', $results['success'] ? 'true' : 'false');
$xml->writeElement('errors', addslashes(htmlentities(implode('<br/>', $results['messages']))));
if (count($results['messages']) > 0) {
	$xml->writeElement('messages', addslashes(htmlentities(implode('<br/>', $results['messages']))));
}

$xml->endElement();

echo $xml->outputMemory(true);
?>